// Author: Zhang Yisong(zhang_yisong@foxmail.com)

#ifndef __CORO_SYNC_WAIT_HPP__
#define __CORO_SYNC_WAIT_HPP__

#include "async_result.hpp"
#include "async_task.hpp"

namespace coro {

template <typename T, typename... TArgs>inline auto SyncWait(T awaitable, TArgs... args) {
  auto pendable = awaitable(GetGlobalContext(), args...);
  pw::async2::Dispatcher d;
  auto ret = d.RunPendableToCompletion(pendable);
  return ret;
}

} // namespace coro

#endif // !__CORO_SYNC_WAIT_HPP__